package com.sky.d_thread.demo;

/**
 * 现在有T1、T2、T3三个线程，你怎样保证T2在T1执行完后执行，T3在T2执行完后执行
 * @Author:hjt
 */
public class Demo1 {

	static class T1 extends Thread {
		
		int i = 0;
		@Override
		public void run() {
			System.out.println("T1 start");
			while (true){
				i ++;
				if(i < 1000000){
					System.out.println("T1 end");
					break;
				}
			}
		}
	}
	
	static class T2 extends Thread {
		
		int i = 0;
		@Override
		public void run() {
			System.out.println("T2 start");
			while (true){
				i ++;
				if(i < 1000000){
					System.out.println("T2 end");
					break;
				}
			}
		}
	}

	static class T3 extends Thread {
		
		int i = 0;
		@Override
		public void run() {
			System.out.println("T3 start");
			while (true){
				i ++;
				if(i < 1000000){
					System.out.println("T3 end");
					break;
				}
			}
		}
	}
	
	public static void main(String[] args) throws InterruptedException {
		Thread t1 = new T1();
		Thread t2 = new T2();
		Thread t3 = new T3();
		
		t1.start();
		t1.join();
		
		t2.start();
		t2.join();
		
		t3.start();
		t3.join();
		System.out.println("执行结束");
	}
}
